<template>
    <div class="custom-dialog">
        <el-dialog :model-value="dialogVisible" :width="width">
            <div class="dialog-header flcc">
                {{ title || '提示' }}
            </div>
            <div class="dialog-content">
                <slot></slot>
            </div>
            <div class="dialog-footer" :class="tips ? 'flbc' : 'flec'">
                <template v-if="tips">
                    <slot name="tips"></slot>
                </template>

                <div class="flec">
                    <div class="dialog-footer-btn divButton mr20 flcc" @click="handleClose"
                        v-if="dialogOptions.showClose">{{
                            dialogOptions.close
                        }}</div>
                    <div class="dialog-footer-btn divButton mr30 flcc active" @click="handleConfirm"
                        v-if="dialogOptions.showConfirm">{{
                            dialogOptions.confirm
                        }}</div>
                </div>

            </div>
        </el-dialog>
    </div>
</template>

<script setup>
const props = defineProps({
    title: {
        type: String,
        default: ''
    },
    width: {
        type: String,
        default: '50%'
    },
    dialogVisible: {
        type: Boolean,
        default: true
    },
    options: {
        type: Object,
        default: () => {
            return {
                showClose: true,
                showConfirm: true,
                confirm: '确定',
                close: '关闭'
            }
        }
    },
    tips: {
        type: Boolean,
        default: false
    }
})


const dialogOptions = computed(() => {
    return {
        showClose: props.options.showClose || true,
        showConfirm: props.options.showConfirm || true,
        confirm: props.options.confirm || '确定',
        close: props.options.close || '关闭'
    }
})
const emit = defineEmits(['confirm', 'close'])


const handleConfirm = () => {
    emit('confirm')
}

const handleClose = () => {
    emit('close')
}
</script>

<style lang="scss" scoped>
.dialog-header {
    width: 100%;
    height: 66px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    font-size: 18px;
    color: #333333;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(153, 153, 153, 0.12);
}

.dialog-content {
    width: 100%;
}

.dialog-footer {
    width: 100%;
    border-top: 1px solid rgba(153, 153, 153, 0.12);
    box-sizing: border-box;
    height: 66px;
}

.dialog-footer-btn {

    height: 36px;
    box-sizing: border-box;
    padding: 0 30px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    font-size: 14px;
    border-radius: 4px 4px 4px 4px;
    border: 1px solid #014099;
    color: #014099;

    &.active {
        color: #FFFFFF;
        background: #014099;
    }

}
</style>
